#!/usr/bin/env python
import os
import sys
if os.path.exists('/home/chieh/code/wuML'):
sys.path.insert(0,'/home/chieh/code/wuML')
import wuml
import numpy as np
regression test
data is designed such that x₁, x₂ has minor positive impact x₄ has major negative,
5x₁ + x₂ + x₁x₂ - 8x₄ - 2x₄x₄ + δ
data = wuml.wData('../../data/shap_regress_example_gaussian.csv', first_row_is_label=True,
label_type='continuout', label_column_name='label', preprocess_data='center and scale')
model = wuml.regression(data, regressor='linear')
E = wuml.explainer(data, model, explainer_algorithm='shap')
exp = E(data)
0%| | 0/30 [00:00<?, ?it/s]
| Most chosen | |
|---|---|
| A | 15 |
| D | 14 |
| B | 1 |
| C | 0 |
| Most weighted | |
|---|---|
| D | 194.980919 |
| A | 170.815480 |
| B | 33.496118 |
| C | 10.028097 |
classification test
data = wuml.wData('../../data/shap_classifier_example.csv', first_row_is_label=True,
label_type='discrete', label_column_name='label')
model = wuml.classification(data, classifier='LogisticRegression')
E = wuml.explainer(data, model, explainer_algorithm='lime')
exp = E(data)
| Most chosen | |
|---|---|
| D | 30 |
| B | 0 |
| C | 0 |
| A | 0 |
| Most weighted | |
|---|---|
| D | 16.651401 |
| B | 2.784209 |
| A | 2.007877 |
| C | 0.870463 |